home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / rebuild-gcj-db < prev    next >
Encoding:
Text File  |  2007-02-16  |  1.7 KB  |  95 lines

  1. #! /bin/bash
  2.  
  3. set -e
  4.  
  5. if [ $# -gt 1 ]; then
  6.     cat 1>&2 <<-EOF
  7.     rebuild-gcj-db: re-build the gcj classmap database
  8.     
  9.     usage: $0 [install|remove]
  10.     EOF
  11.     exit 1
  12. fi
  13.  
  14. mode=install
  15. case "$1" in
  16.     install|remove)
  17.     mode=$1;;
  18. esac
  19.  
  20. uname=$(uname -m)
  21.  
  22. rebuild_db()
  23. {
  24.     dbtool=$1; shift
  25.     dbLocation=$1; shift
  26.     dirs=
  27.  
  28.     for dir; do [ -d $dir ] && dirs="$dirs $dir"; done
  29.     if [ -z "$dirs" ]; then
  30.     # no more dirs with .db files on the system
  31.     return 0
  32.     fi
  33.     mkdir -p $(dirname $dbLocation)
  34.     if $dbtool -n $dbLocation.tmp 64; then
  35.     case "$uname" in arm*|m68k|parisc*)
  36.         echo >&2 "$dbtool succeeded unexpectedly"
  37.     esac
  38.     else
  39.     case "$uname" in
  40.         arm*|m68k|parisc*)
  41.             echo >&2 "ERROR: $dbtool did fail; known problem on $uname"
  42.         return 0;;
  43.         *)
  44.         exit 2
  45.     esac
  46.     fi
  47.     find $dirs -follow -name '*.db' -print0 | \
  48.     xargs -r -0 $dbtool -m $dbLocation.tmp $dbLocation.tmp || exit 1
  49.     mv $dbLocation.tmp $dbLocation
  50. }
  51.  
  52.  
  53. rebuild_databases()
  54. {
  55.     v=$1
  56.     dbtool=gcj-dbtool-$1
  57.     dbLocation=`$dbtool -p || true`
  58.  
  59.     if [ -n "$dbLocation" ]; then
  60.     case "$uname" in arm*|m68k|parisc*)
  61.         echo >&2 "$dbtool succeeded unexpectedly"
  62.     esac
  63.     else
  64.     case "$uname" in
  65.         arm*|m68k|parisc*)
  66.             echo >&2 "ERROR: $dbtool did fail; known problem on $uname"
  67.         return 0;;
  68.         *)
  69.         exit 2
  70.     esac
  71.     fi
  72.  
  73.     if [ "$mode" = remove ] && [ ! -f "$dbLocation" ]; then
  74.     # libgcj7-0 or libgcj8 are already removed; no need
  75.     # to rebuild anything
  76.     return 0
  77.     fi
  78.     rebuild_db \
  79.     $dbtool \
  80.     $dbLocation \
  81.     /usr/share/gcj/classmap.d \
  82.     /usr/share/gcj-$v/classmap.d
  83. }
  84.  
  85. # still two different databases for gcj-4.1 and gcj-4.2
  86.  
  87.  
  88. if [ -x /usr/bin/gcj-dbtool-4.1 ]; then
  89.     rebuild_databases 4.1
  90. fi
  91.  
  92. if [ -x /usr/bin/gcj-dbtool-4.2 ]; then
  93.     rebuild_databases 4.2
  94. fi
  95.